package gates;
import java.awt.Graphics;

import master.*;

/**
 * 
 * @author Matthew & Oliver
 * 
 * A way of implementing the conditional phase shift, the 3rd stage of grovers algorithm
 * 
 * Basically it flips all values by PI radians apart from zero 
 * (which is the state it must currently start in)
 * 
 */

public class CondPhaseShift extends QuantumGate {

	private int start;
	
	public CondPhaseShift(int start){
		this.start = start;
	}


	public void actOnReg(QuantumRegister register) {
		
	
		
		for (int i = 0; i < register.getDimension(); i ++){
			if(i != start ){
					
			ComplexNumber temp = register.getCoefficient(i).multByNo(-1f);
			register.setCoefficient(temp, i);
		
			}
		}
	}


	


	@Override
	public int[] getActingBits() {
		// Acts on whole register, not individual bits
		int a[] = new int[1];
		a[0] = -1;		
		return a;
	}

}